<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\common\model;

use think\Model as ThinkModel;

//银行列表模型
class Users extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__QT_USERS__';
    protected $name = 'qt_users';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;

    /**
     * 检测用户登录状态
     * @param $data
     * @return int
     */
    public  function checkUser($data){

        $user_info = $this->where('phone',$data['phone'])->find();
        if($user_info){
            if($user_info->status == 1){
                return 10002;//用户被禁用
            }
            if(pwd($data['password'],$user_info->ivt_code) == $user_info->password){
                return 2000;
            }else{
                return 10003;//账号密码错误
            }
        }
        return 10001;//用户不存在请去登录
    }
}